/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.spring.modelo.DAO;

import com.spring.modelo.entidad.Semestre;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

/**
 *
 * @author Duber Hugo Troncos Siancas(duberhugo3@hotmail.com)
 */
@Repository
public class SemestreDAO extends HibernateDaoSupport  {
    @Autowired
            public SemestreDAO(SessionFactory sf){
        super.setSessionFactory(sf);
    }
    public List<Semestre> ListarSemestre(){
        return getHibernateTemplate().find("Select s from Semestre s");
    }
    public boolean insertarSemestre(Semestre s){
        boolean b=false;
        try{
            getHibernateTemplate().saveOrUpdate(s);
            b=true;
        }catch(Exception e){
            e.printStackTrace();
            b=false;
        }
        return b;
    }
    public Semestre buscarSemestre(String codigo){
        return getHibernateTemplate().get(Semestre.class, codigo);
    }
    public boolean eliminarSemestre(String codigo){
        boolean  b=false;
        try{
            getHibernateTemplate().delete(buscarSemestre(codigo));
            b=true;
        }catch(Exception e){
            e.printStackTrace();
        }
        return b;
    }
}
